﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DropDownTreeControl.ascx.cs" Inherits="ZLCMS.Web.SystemManage.Control.ddt.DropDownTreeControl" %>

<style type="text/css">
.floatdiv{display:none;position:relative; height:200px; width:300px; background-color:white;border:1px solid;overflow-y:auto;overflow-x:auto; z-index: 9999;}
</style>

    <asp:TextBox ID="txtNodeText" runat="server" ReadOnly="True"></asp:TextBox>
    <a id="menuBtn" class="btnLook" href="#" onclick="showMenu(); return false;"></a>
    <input id="inpNodeValue" runat="Server" type="hidden" />
     <dl>           
        <div id="DropdownMenuBackground" class="floatdiv">
            <ul id="<%=Guid.NewGuid().ToString() %>" class="ztree"  tid="<%=Request["uid"] %>"  setting='
{
	view: {
		selectedMulti: false
	},
    data: {
		key: {
			name: "Name"
		},
		simpleData: {
			enable: true,
			idKey: "Id",
			pIdKey: "ParentId"
		},
		keep: {
			parent: false,
			leaf: false
		}
	},
	async: {
		enable: true,
		type: "post",
		url: "<%= AsyncUrl %>",
        otherParam: ["temp", new Date().valueOf()]
	},
    edit: {
		enable: false,
		editNameSelectAll: false,
		showRemoveBtn: false,
		showRenameBtn: false
	},
	callback: {
		beforeDrag: function (treeId, treeNodes) {
			return false;
		},
        onAsyncSuccess:function(event, treeId, treeNode, msg){
            $.fn.zTree.getZTreeObj(treeId).expandAll(true);
        },
        onClick:function(event, treeId, treeNode, clickFlag){
            $("#<%=txtNodeText.ClientID %>", navTab.getCurrentPanel()).val(treeNode.Name);
            $("#<%=inpNodeValue.ClientID %>", navTab.getCurrentPanel()).val(treeNode.Id);
            hideMenu();
        }
	}
}
'></ul>
        </div>	  
    </dl>
    
<script type="text/javascript">

    $(document).ready(function() {
        
        //hideMenu();
        

        $("body").bind("mousedown",
			function(event) {
			    if (!(event.target.id == "menuBtn" || event.target.id == "DropdownMenuBackground" || $(event.target).parents("#DropdownMenuBackground").length > 0)) {
			        hideMenu();
			    }
			});
    });

    function showMenu() {
        $("#DropdownMenuBackground", navTab.getCurrentPanel()).show();
    }
    function hideMenu() {
        $("#DropdownMenuBackground", navTab.getCurrentPanel()).hide();
    }


</script>
<%--
<script type="text/javascript">
    //添加节点
    function addItem(treeId, Node) {
        var pid;

        if (Node) {
            pid = Node.ParentId;
        }

        var node = new Object();
        node.Name = "新的菜单";
        node.Id = Node.Id;

        //当为根节点添加子菜单时 pid==0
        if (pid == undefined) {
            pid = 0;
        }
        node.ParentId = pid;

        node.temp = new Date().valueOf();
        var json = $.toJSON(node);

        $.get("/SystemManage/Basics/TypeTree/TypeTree.aspx", { opt: "add", node: json }, function (data) {

            var zTree = $.fn.zTree.getZTreeObj(treeId);
            if (Node) {
                zTree.addNodes(Node, $.parseJSON(data));
            } else {
                zTree.addNodes(null, $.parseJSON(data));
            }
        });
    }

    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0) return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
				+ "' title='增加子菜单' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.tId);
        if (btn) btn.bind("click", function () {
            addItem(treeId, treeNode);
            return false;
        });
    };
    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_" + treeNode.tId).unbind().remove();
    };

</script>--%>